<template>
  <div class="wrap">
    <div class="block">
      <el-form class="form">
        <h1 style="display: block;margin: auto">F Blog</h1>

        <el-form-item label="用户名" label-width="100px">
          <el-input type="text" v-model="user.userName"></el-input>
        </el-form-item>

        <el-form-item label="密码" label-width="100px">
          <el-input type="password" v-model="user.userPassword"></el-input>
        </el-form-item>

        <el-form-item label="确认密码" label-width="100px">
          <el-input type="password" v-model="checkPassword"></el-input>
        </el-form-item>

        <el-form-item label-width="300px">
          <el-button v-text="'注册'" @click="register"></el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import {login, register} from "../../request/request";

export default {
  name: "UserRegister",

  data() {
    return {
      user: {
        userName: '',
        userPassword: '',
      },

      checkPassword: '',

    }
  },

  methods: {
    register() {
      if (this.checkPassword !== this.user.userPassword) {
        this.$message.warning('两次输入的密码不一致');
        return
      }


      this.$request.register(this.user).then((data) => {

        if (data.code === 200) {
          this.$message.success('操作成功')
        }
      })
    }
  }


}
</script>

<style scoped>

</style>
